from twisted.python.util import println


class Employee(object):
    def __init__(self, name):
        self._name = name


    @property
    def name(self):
        println("输出名字")
        return self._name

    @name.setter
    def name(self, name):
        println("输入名称")
        self._name = name


    def getSalary(self):
        pass


class Boss(Employee):
    def __init__(self, name):
        super().__init__(name)


    def salary(self):
        return 15000


class Programmer(Employee):
    def __init__(self, name, workhour=0):
        super().__init__(name)
        self._workhour = workhour

    def salary(self):
        return self._workhour * 100

    @property
    def workhour(self):
        println("输出工时")
        return self._workhour

    @workhour.setter
    def workhour(self, workhour):
        println("输入工时")
        self._workhour = workhour


class Saleman(Employee):
    def __init__(self, name, saleamounts=0):
        super().__init__(name)
        self._saleamounts = saleamounts

    def salary(self):
        return self._saleamounts * 0.1

    @property
    def saleamount(self):
        println("输出销售额")
        return self._saleamount

    @saleamount.setter
    def saleamount(self, saleamount):
        println("输入销售额")
        self._saleamount = saleamount




if __name__ == '__main__':
    emps = [Boss("老王"), Saleman("李霞"), Programmer("團長")]
    for emp in emps:
        if isinstance(emp, Saleman):
            emp.saleamount = 100000
            println("%s 销售额 %d, 销售额 %f" % (emp.name, emp.saleamount, emp.salary()))
        elif isinstance(emp, Programmer):
            emp.workhour = 100
            println("%s 工时 %d, 薪资 %f" % (emp.name, emp.workhour, emp.salary()))
        else:
            emp.salary()
            println("%s是老板，薪资%f" % (emp.name, emp.salary()))

